<template>
  <el-row class="content-wrapper" :gutter="20">
    <el-col class="item-box" :span="6">
      <el-card shadow="hover" class="data-card" :body-style="{ padding: '5px 30px' }">
        <div class="content">
          <div class="data-wrapper">
            <div class="title">{{ $t('wms.actualTotal') }}</div>
            <div class="value">
              <span class="number">{{ data.lineCount.totalQty || 0.00 }}</span>
            </div>
          </div>
          <div class="chart-wrapper">
            <!-- <img class="imgs" src="http://screen.bjdnlsj.com/afl-data-screen/images/icon-all-input.png"> -->
          </div>
        </div>
      </el-card>
    </el-col>
    <el-col class="item-box" :span="6">
      <el-card shadow="hover" class="data-card" :body-style="{ padding: '5px 30px' }">
        <div class="content">
          <div class="data-wrapper">
            <div class="title">{{ $t('wms.actualTotalInput') }}</div>
            <div class="value">
              <span class="number">{{ data.lineCount.totalInput || 0 }}</span>
            </div>
          </div>
          <div class="chart-wrapper">
            <!-- <liquid-fill :num="Number(data.totalInput || 0)"></liquid-fill> -->
          </div>
        </div>
      </el-card>
    </el-col>
    <el-col class="item-box" :span="6">
      <el-card shadow="hover" class="data-card" :body-style="{ padding: '5px 30px' }">
        <div class="content">
          <div class="data-wrapper">
            <div class="title">{{ $t('wms.extrapolatingTotal') }}</div>
            <div class="value">
              <span class="number">{{ data.lineCount.calculatedOutputQty || 0 }}</span>
            </div>
          </div>
          <div class="chart-wrapper">
            <!-- <liquid-fill :num="Number(data.calculatedOutputQty || 0)"></liquid-fill> -->
          </div>
        </div>
      </el-card>
    </el-col>
    <el-col class="item-box" :span="6">
      <el-card shadow="hover" class="data-card" :body-style="{ padding: '5px 30px' }">
        <div class="content">
          <div class="data-wrapper">
            <div class="title">{{ $t('wms.imputedTotal') }}</div>
            <div class="value">
              <span class="number">{{ data.lineCount.totalActualInput || 0 }}</span>
            </div>
          </div>
          <div class="chart-wrapper">
            <!-- <liquid-fill :num="Number(data.totalActualInput || 0)"></liquid-fill> -->
          </div>
        </div>
      </el-card>
    </el-col>
  </el-row>
</template>

<script setup>
import { reactive, ref, watch, onMounted, defineProps } from 'vue'
import { CountTo } from 'vue3-count-to'
import liquidFill from '@/components/common/liquidFill'
import { processInputOutputTotal } from '@/api/mesApi'

const data = reactive({
  lineCount: '',
  classes: '',
  period: []
})

const props = defineProps({
  classes: { type: String },
  period: { type: Array },
  lineCode: { type: String }
})

watch(() => [props.classes, props.period, props.lineCode], () => {
  // console.log(props.classes, props.period[0], props.period[1])
  data.classes = props.classes
  data.period = props.period
  // console.log(data.period[0], data.period[1])
  if (data.period[0] !== undefined && data.period[0].length === undefined) {
    data.period[0] = data.period[0].toLocaleDateString()
    data.period[1] = data.period[1].toLocaleDateString()
  }
  // getJJGTabulateDataList()
  procesTotal()
})
onMounted(() => {
  procesTotal()
  setTime()
})
// 定时执行
const setTime = () => {
  setInterval(async () => {
    await procesTotal()
  }, 6000)
}
// 产出汇总
const procesTotal = () => {
  processInputOutputTotal({
    processCode: props.lineCode.indexOf('JC') === 0 ? 'JC' : props.lineCode,
    mesProduceDate: data.period[0] || '',
    mesProduceDate1: data.period[1] || '',
    shiftCode: data.classes === 'All' ? '' : data.classes,
    lineCode: props.lineCode
  }).then(res => {
    if (res.status === 200 && res.data != null) {
      data.lineCount = res.data.totalMap
    }
  })
}

</script>

<style scoped lang="scss">
.content-wrapper {
  padding: 10px 0;
  height: 100%;

  .el-card__body {
    padding: 20px;
  }

  .data-card {
    border-radius: 10px;
    color: #999;

    .content {
      display: flex;
      flex-direction: row;
      justify-content: space-between;

      .data-wrapper {}

      .chart-wrapper {
        margin-left: 10px;

        .imgs {
          height: 120px;
          width: 120px;
        }
      }

      .title {
        //color: #C0C4CC;
        font-weight: 600;
        font-size: 16px;
        line-height: 2.5;
        letter-spacing: 2px;
      }

      .value {
        font-weight: 700;
        font-size: 40px;
        color: black;
        line-height: 2;
      }

      .total {
        font-weight: 700;
        font-size: 14px;
      }
    }
  }
}

.number {
  font-weight: 700;
  font-size: 40px;
  color: #000;
  line-height: 2;
}
</style>
